
<ul class="layui-nav layui-layout-left">
              <!-- 移动端显示 -->
     <li class="layui-nav-item layui-show-xs-inline-block layui-hide show_menu" lay-header-event="showMenu" lay-unselect>
        <a href="javascript:;"><i class="layui-icon layui-icon-spread-left"></i></a>
    </li>  
    <li class="layui-nav-item layui-show-md-inline-block layui-hide-xs  hide_menu" lay-header-event="hideMenu" lay-unselect>
        <a href="javascript:;"><i class="layui-icon layui-icon-shrink-right"></i></a>
    </li>  
                
    <li class="layui-nav-item layui-this layui-hide-xs layui-show-md-inline-block">
        <a title="" href="javascript:;" id="consoles">
            控制台
        </a>
    </li>
    
        <!-- <li class="layui-nav-item">
          <a href="javascript:;">nav groups</a>
          <dl class="layui-nav-child">
            <dd><a href="">menu 11</a></dd>
            <dd><a href="">menu 22</a></dd>
            <dd><a href="">menu 33</a></dd>
          </dl>
        </li> -->
</ul>
<ul class="layui-nav layui-layout-right">
    <!-- 如果有新消息，则显示小圆点 -->
<!-- <li class="layui-nav-item layui-hide-xs " lay-unselect="lay-unselect">
    <a lay-href="app/message/" layadmin-event="message">
        <i class="layui-icon layui-icon-notice"></i>
        
     
        </script>  <span class="layui-badge-dot"></span>  
        
    </a>
</li>
<li class="layui-nav-item layui-hide-xs " lay-unselect="lay-unselect">
        <a href="{:url('index/Index/index','',true,true)}" target="_blank" title="前台">
            <i class="layui-icon layui-icon-website"></i>
        </a>
</li> -->
<li class="layui-nav-item layui-hide-xs" lay-unselect="lay-unselect">
    <a href="javascript:location.reload();" layadmin-event="refresh" title="刷新">
        <i class="layui-icon layui-icon-refresh-3"></i>
    </a>
</li>
<!-- layui-show-md-inline-block -->
<li class="layui-nav-item  ">
    <a href="javascript:;" id="login-user">
 
    </a>
    <dl class="layui-nav-child">
        <dd><a href="javascript:;" class="clear-file">清除缓存</a></dd>
        <dd><a href="javascript:;" class="login-user-info">基本资料</a></dd>
        <hr>
        <dd><a href="javascript:;" class="logout">退出登录</a></dd>
    </dl>
</li>
<li class="layui-nav-item" lay-header-event="menuRight" lay-unselect>
    <a href="javascript:;">
    <i class="layui-icon layui-icon-more-vertical"></i>
    </a>
</li>
</ul>

<script>
    //登录的用户
    var http = new Request({token_url:api.token_url,async:false,token_store_name:'admin'});
    var res = http.request('post',api.login_user);
    if(res.code == 0){
        $("#login-user").html('<img src="'+res.data['img_src']+'" class="layui-nav-img">'+res.data['user']+'');
         //基本资料页面
        $(".login-user-info").attr("href",api.base_url+"?id="+res.data['id']+"#"+api.login_user_info);
    }
    $("#consoles").attr('href',api.base_url+"#"+api.consoles);
   

    //JS 
    layui.use(['element', 'layer', 'util'], function(){
      var element = layui.element
      ,layer = layui.layer
      ,util = layui.util
      ,$ = layui.$;
      //退出登录
      $(".clear-file").on("click",function(){
            var http = new Request({token_url:api.token_url,async:false,token_store_name:'clear-file'});
            var res = http.request('post',api.clear_url);
            if(res.code == 0){
                layer.msg(res.msg);
                return true;
            }
            layer.msg(res.msg,function(){});
            return false;
        });
       //退出登录
       $(".logout").on("click",function(){
            var http = new Request({token_url:api.token_url,async:false,token_store_name:'logout'});
            var res = http.request('post',api.logout);
            if(res.code == 0){
                layer.msg(res.msg);
                window.location.href = api.login_url;
                return true;
            }
            layer.msg(res.msg,function(){});
            return false;
        });  
      //头部事件
      util.event('lay-header-event', {
        //左侧菜单事件
        showMenu: function(othis){
          $(".show_menu").addClass("layui-hide").removeClass("layui-show-xs-inline-block").removeClass("layui-show-sm-inline-block").removeClass("layui-show-md-inline-block");
          $(".hide_menu").removeClass("layui-hide").addClass("layui-show-xs-inline-block layui-show-sm-inline-block layui-show-md-inline-block");
          $(".layui-layout-admin .layui-side").css("left",0);
          $(".layui-header .layui-logo").addClass("layui-show-xs-inline-block layui-show-sm-inline-block layui-show-md-inline-block");
          $(".layui-header .layui-layout-left").css("left",170);
          $(".layui-layout-admin .layui-footer").css("left",170);
          $(".layui-layout-admin .layui-body").css("left",170);
        },
        hideMenu: function(othis){
          $(".hide_menu").addClass("layui-hide").removeClass("layui-show-xs-inline-block").removeClass("layui-show-sm-inline-block").removeClass("layui-show-md-inline-block");
          $(".show_menu").removeClass("layui-hide").addClass("layui-show-xs-inline-block layui-show-sm-inline-block layui-show-md-inline-block");
          $(".layui-layout-admin .layui-side").css("left",-300);
          $(".layui-header .layui-logo").addClass("layui-hide").removeClass("layui-show-xs-inline-block").removeClass("layui-show-sm-inline-block").removeClass("layui-show-md-inline-block");
          $(".layui-header  .layui-layout-left").css("left",0);
          $(".layui-layout-admin .layui-footer").css("left",0);
          $(".layui-layout-admin .layui-body").css("left",0);
        },
        menuRight: function(){
        //   layer.open({
        //     type: 1
        //     ,content: '<div style="padding: 15px;">处理右侧面板的操作</div>'
        //     ,area: ['260px', '100%']
        //     ,offset: 'rt' //右上角
        //     ,anim: 5
        //     ,shadeClose: true
        //   });
        }
      });
      
    });
    </script>

 

   